package com.xywy.tangandroid.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

import com.xywy.tangandroid.bean.User;

public class Constant {
	public static final int ALBUM = 2014;// 相册
	public static final int PHOTOGRAPH = 2015;// 拍照
	public static boolean flag = true;// 控制popwindow的开关
	public static boolean flag_vocation = true;// 控制popwindow的开关
	public static boolean flag_blood = true;// 控制popwindow的开关

	public static String url = "http://api.wws.xywy.com/index.php?";
	public static String Sign = "KHy69gsk8%#@kl$";// 数字签名验证
	public static String tag = "TangAndroid";
	public static String wjkTag = "wjk";

	public static final String NAME_MATCH = "^[\u4E00-\u9FA5]{2,8}$";// 2至8个汉字的
	public static final String PHONE_MATCH = "^1[0-9]{10}$";// 手机号正则

	public static final String PASSWORD = "^[0-9a-zA-Z]{6,16}$";// 6之

	public static final String NUMBER = "^[0-9]$";// 数字
	public static String PPROVINCE = "";// 省份的记录
	public static String PROFESSION = "";// 职称的记录

	public static final String send_doctor_url = "http://api.club.xywy.com/familyDoc_api.php?";// 提交问题给医生本人
	public static final String key = "PQ8hje78sx112pRuktvVZ";// 提交问题给医生本人的key

	public static final String blood_url = "http://api.yun.xywy.com/index.php/api/setdata/data_all/";

	public static final String COllection_url = "http://api.yun.xywy.com/index.php/glu_app/"
			+ "collect/is_collected/?" + "&tag=" + tag;
	public static final String IsCOllection_url = "http://api.yun.xywy.com/index.php/glu_app/collect/post/?"
			+ "&tag=" + tag;
	public static final String getCOllection_url = "http://api.yun.xywy.com/index.php/glu_app/collect/list_data/?";

	public static String getBloodListUrl = "http://api.yun.xywy.com/index.php/api/getdata/xuetang?";// 获取血糖数据的

	public static String datatime;// 删除血压的数据时间
	public static String app_data;// 删除血压的测试的值
	public static String shou_data;// 删除血压的手动的值
	public static int postion;// 删除第几条血压的数据

	/**
	 * 消息类请求统一url
	 */
	public static final String MESSAGE_URL = "http://api.yun.xywy.com/index.php/glu_app/ad";

	/**
	 * 获取请求的url的拼接
	 * 
	 * @return
	 */
	public static String getUrl(String act, String fun) {

		try {
			String sign = MD5.md5s(Sign + tag);
			if (act != null && fun != null) {
				return url + "tag=" + tag + "&sign=" + sign + "&act=" + act
						+ "&fun=" + fun;
			} else {
				// 上传图片的
				return "http://api.wws.xywy.com/upload.php?" + "&tag=" + tag
						+ "&sign=" + sign;
			}
		} catch (Exception e) {

			e.printStackTrace();
			return "-100";
		}

	}

	/**
	 * 提交问题给专家本人
	 * 
	 * @param act
	 * @return
	 */
	public static String getSendToDoctorUrl(String act, Context context) {

		try {
			String sign = MD5.md5s(key
					+ User.getIUserInstance(context).getUserid());
			if (act != null)
				return send_doctor_url + "&act=" + act;

		} catch (Exception e) {

			e.printStackTrace();
			return "-100";
		}
		return "-10";

	}

	/**
	 * 提交问题给专家本人的key+uid的 加密
	 * 
	 * @return
	 */
	public static String getKeyAndUid(Context context) {

		try {
			String sign = MD5.md5s(User.getIUserInstance(context).getUserid()
					+ key);
			return sign;
		} catch (Exception e) {
			e.printStackTrace();
			return "-100";
		}
	}

	public static final String pwd = "w1YTJSps7tKJ";// 血糖暗码

	/**
	 * 血糖上传数据的sign
	 * 
	 * @return
	 */
	public static String getBloodSign(String data, Context context) {
		try {
			String sign = MD5.md5s(pwd
					+ User.getIUserInstance(context).getUserid() + "xuetang"
					+ data + "xywy_xuetang");
			return sign;
		} catch (Exception e) {
			e.printStackTrace();
			return "-100";
		}

	}

	public static ArrayList<String> province = new ArrayList<String>();
	public static Map<Integer, String> profession_info = new HashMap<Integer, String>();
	public static ArrayList<String> profession = new ArrayList<String>();

	public static ArrayList<String> Testslot = new ArrayList<String>();
	static {
		province.add("不限");
		province.add("北京市");
		province.add("山东省");
		province.add("山西省");
		province.add("河北省");
		province.add("河南省");
		province.add("天津市");
		province.add("辽宁省");
		province.add("黑龙江省");
		province.add("吉林省");
		province.add("湖北省");
		province.add("湖南省");
		province.add("上海市");
		province.add("四川省");
		province.add("重庆市");
		province.add("陕西省");
		province.add("甘肃省");
		province.add("云南省");
		province.add("新疆维吾尔自治区");
		province.add("内蒙古自治区");
		province.add("海南省");
		province.add("贵州省");
		province.add("青海省");
		province.add("广东省");
		province.add("宁夏回族自治区");
		province.add("西藏自治区");
		province.add("广西壮族自治区");
		province.add("江苏省 ");
		province.add("浙江省");
		province.add("安徽省");
		province.add("江西省");
		province.add("福建省");

		profession_info.put(1, "主任医师");
		profession_info.put(2, "副主任医师");
		profession_info.put(3, "主治医师");
		profession_info.put(5, "医师");// 医师 就是 住院医师

		profession.add("不限");
		profession.add("主任医师");
		profession.add("副主任医师");
		profession.add("主治医师");
		profession.add("医师");

		Testslot.add("凌晨(空腹)");
		Testslot.add("早餐后");
		Testslot.add("午餐前");
		Testslot.add("午餐后");
		Testslot.add("晚餐前");
		Testslot.add("晚餐后");

	}

	/**
	 * @param con
	 * @param isFirst
	 *            0：此账号第一次登录 1：第二次 是否显示引导页的问题
	 */
	public static void saveFirstLogin(Context con, String isFirst) {
		SharedPreferences sp = con.getSharedPreferences("isFirst",
				Activity.MODE_PRIVATE);
		sp.edit().putString("isFirst", isFirst).commit();
	}

	public static String getFirstLogin(Context con) {
		SharedPreferences sp = con.getSharedPreferences("isFirst",
				Activity.MODE_PRIVATE);
		return sp.getString("isFirst", "0");
	}
}
